<extend name="Comon:laout"/>

<block name="cont">

<div class="Inside_pages">
 <div class="shop_carts">
   <div class="Process"></div>
 <div class="Shopping_list">
  <div class="title_name">
    <ul>
  <li class="checkbox"></li>
  <li class="name">商品名称</li>
  <li class="scj">市场价</li>
  <li class="bdj">本店价</li>
  <li class="sl">购买数量</li>
  <li class="xj">小计</li>
  <LI class="cz">操作</LI>
  </ul>
 </div>
  <div class="shopping">
  <form  method="post" action="{:U('home/goods/pay')}" id="post">
        <input type="hidden" name="total_price" value=''>

       <table class="table_list">
                <foreach name='list' item='v'>
                 <tr class="tr">
                 <td class="checkbox">
                    <input name="checkitems" type="checkbox" class="check" value="" cartid = {$v.id}>
                 </td>
                  <td class="name">
                  <div class="img"><a href="#"><img src="__ROOT__{$v.img}" /></a></div>
                  <div class="p_name"><a href="#">{$v.name}&nbsp;{$v.desc}</a></div>
                  <input id="nm" type="hidden" value ="{$v.name}">
                  <input id="de" type="hidden" value ="{$v.desc}">
                </td>
                <td class="scj sp"><span id="Original_Price_1">￥{$v.goods_price}</span></td>
                <td class="bgj sp" ><span id="price_item_1">￥{$v.spec_price}</span></td>
                <td class="sl">
                    <div class="Numbers">
                    <a  href="javascript:void(0)" class="jian">-</a>
                        <input type="text" name="qty_item_" value="{$v.num}" id="qty_item_1" onkeyup="setAmount.modify('#qty_item_1')" class="number_text">
                    <a  href="javascript:void(0)" class="jia">+</a>
                   </div>
                </td>

                <td class="xj" >￥<span class="total" id="total_item_1">{$v[spec_price]*$v[num]}</span></td>

                <td class="cz">
                   <p><a href="#">删除</a><P>
                   <p><a href="#">收藏该商品</a></p>
                </td>
               </tr>
                <input type="hidden" name="" class="count" value="{:count($list)}">
              </foreach>
       <!--  $('form').submit(); -->
       </table>
 <div class="sp_Operation clearfix">
  <div class="select-all">
  <div class="cart-checkbox"><input type="checkbox"   id="CheckedAll" name="toggle-checkboxes" class="jdcheckbox" clstag="clickcart">全选</div>
  <div class="operation"><a href="javascript:void(0);" id="send">删除选中的商品</a></div>
    </div>
   <!--结算-->
  <div class="toolbar_right">
    <ul class="Price_Info">
    <li class="p_Total"><label class="text" id="total">商品总价：</label><span class="price sumPrice" id="Total_price"></span></li>
  <li class="Discount"><label class="text">以&nbsp;&nbsp;节&nbsp;&nbsp;省：</label><span class="price" id="Preferential_price"></span></li>
    <li class="integral">本次购物可获得<b id="total_points"></b>积分</li>
    </ul>
  <div class="btn">
      <a class="cartsubmit" href="javascript:void(0)"></a>
      <a class="continueFind" href="{:U('home/goods/lists')}"></a>
  </div>
  </div>
  </div>

 </div>
 </div>
 </div>
</div>
</block>
<block name="js">
        <script type=text/javascript>
              $(function(){
                    //给所有的checkbox绑定点击事件
                    $('.check').click(function(){
                        //抓到所有勾选的商品的价格
                        // var len=$("[type='checkbox']:checked").next('.xj').find('span').text();
                        var len=$(":checkbox[name=checkitems]:checked");

                        var leng=$(":checkbox[name=checkitems]:checked").length;
                        var count =$('.count').val();
                        if(leng==count){
                            $('#CheckedAll').prop('checked',true);
                        }

                        var total = 0;
                        len.each(function(i,obj) {
                              total+=Number($(obj).parent().parent().find('.xj span').text());
                        });
                        var txt = '￥'+total;
                        $('.sumPrice').text(txt);
                    })

                    $('#CheckedAll').click(function(){
                        $(":checkbox[name=checkitems]").prop('checked',$(this).is(':checked'));
                        var len=$(":checkbox[name=checkitems]:checked");
                        var total = 0;
                        len.each(function(i,obj) {
                              total+=Number($(obj).parent().parent().find('.xj span').text());
                        });
                        var txt = '￥'+total;
                        $('.sumPrice').text(txt);
                    })

                    $('.cartsubmit').click(function(){
                          var len=$(":checkbox[name=checkitems]:checked");
                          var total = 0;
                          len.each(function(i,obj) {
                                total+=Number($(obj).parent().parent().find('.xj span').text());
                          });

                          // var nm=$('#nm').val();
                          // var de=$('#de').val();

                          // alert(total);return;
                          $('input[name=total_price]').val(total);
                          $('input[name=nm]').val(nm);
                          $('input[name=de]').val(de);
                          $('#post').submit();
                    })

              })
        </script>
</block>